   Concentre.XForms_Element_Control_Abstract = Concentre.Class( Concentre.XForms_Element_Abstract, {
		innerElements: [],
		hasChanged: false,
   		options: {
   		
   		},
   		
   		initialize: function (elt) {
    		//this.superclass.initialize.apply(this, arguments);
    		this.element  =  elt;
   		},
   		
   		handleEvent: function (e) {
   				var f = Concentre.Factory.Events;
				f.stopPropagation(e);

				console.log(e.type);
				
				var t = e.target;				
				var p = t.parentNode;
   			
   				switch (e.type) {
					case 'focus':
						p.addClass('focus');
						
						break;
   					case 'blur':
						p.removeClass('focus');
						
						break;
					case 'keypress':
						
						break;
						
					case 'keydown':
						break;
						
					case 'change':
						this.updateModel();
						break;
   				}
   		},
   		
   		updateModel: function() {
	  		var model  = this.binding.model;
  			var boundNode = this.binding.boundNodes[0];
  		
  			var vertex = model.graph.getVertex(boundNode , "text");
  			vertex.setValue(this.getValue());
 			
 			if (!model.hasChanged()) {
    			return;
  			}		
						
			model.fireEvent('xforms-recalculate');
			model.fireEvent('xforms-revalidate');
			model.fireEvent('xforms-refresh');

			//this.fireEvent('xforms-value-changed');
		},
   		
   		setValue: function () {
   			/* abstract */
   		},
   		
   		getValue: function () {
   			/* abstract */
   		},
   		
   		
		build: function(c,nodeset) {
		
		},

		touch: function() {
 			if (!this.hasChanged && this.refresh) {
    			this.hasChanged = true;
    			this.binding.model.changedControls.push(this);
			 }
		},
		
		setProperty: function(property , value) {
		if (property!='relevant' && this.target.disabled) return;

		switch(property) {
 			case 'readonly': this.setReadonly(value); break;
			case 'required': this.setRequired(value); break;
 			case 'relevant': this.setRelevant(value); break;
			case 'constraint': this.setConstraint(value); break;
			case 'type' : 
					this.setType(value);
					this.fireEvent( concentre.modules.xforms.controls.atom.events[property][value==null] );
					return;
			case 'text': 
			        /*
			        if (!this.inputMask) {
			               var inputMask = concentre.inputmasks.hashTable [ this.binding.datatype ] || concentre.inputmasks.atom;
			               this.inputMask = new inputMask(this);
			        }
			        */

				this.setValue(value);
				return;
			default: return;
		}

		/*
		var model  = this.binding.model;
                var boundNode = this.binding.boundNodes[0];
                var vertex = model.graph.getVertex(boundNode , "text");
		
		this.fireEvent( concentre.modules.xforms.controls.atom.events[property][value] );
		*/
		
		},
		

   		
   		setConstraint: function(value) {
			if (value==false) {
        	       this.element.className = this.element.className+' invalid';
        	} else {
                this.element.className = this.element.className.replace(/\binvalid\b/g, "");
        	}
		},
		
		setRequired: function(value) {
			this.element.className=value?this.element.className+' required':this.element.className.replace(/\brequired\b/g, "");
		},
	
		setReadonly: function(value) {
		this.element.className=value?this.element.className+' readonly':this.element.className.replace(/\breadonly\b/g, "");
		this.target.readOnly = value;
		},

		setRelevant: function(value) {
	  		this.element.className=value?this.element.className.replace(/\bdisabled\b/g, ""):this.element.className+' disabled';
   	  		this.target.disabled = value?false:true;
		},

		setType: function(value) {

			if (value!=null) { 
				this.element.className = this.element.className+' invalid';
			} else {
				this.element.className = this.element.className.replace(/\binvalid\b/g, "");
			}
		
		/*
		if (value!=null) {
				this.error = document.createElement('span');
				this.error.appendChild(document.createTextNode(value));
				this.error.className='invalid';
				
				this.target.parentNode.insertBefore(this.error, this.target.nextSibling);
				this.element.className = this.element.className+' invalid';
		} else {
				this.element.className = this.element.className.replace(/\binvalid\b/g, "");
				if (this.error) {
					this.error.parentNode.removeChild(this.error);	
				}
		}*/
	
		},
   		
		toString: function () {
			return '[ Object Concentré XForms Control Abstract ]';
		}	
   });    	
